<template>
    <diV>
        <div class="table">
            <div class="container">
                <div class="handle-box" style="margin:13px 0;">
                    <span class="demonstration">日期&nbsp;:</span>
                        <el-date-picker
                                v-model="value1"
                                type="datetime"
                                placeholder="选择日期时间"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                >
                        </el-date-picker>
                    <span class="demonstration">内容&nbsp;:</span>
                    <el-input v-model="value2" placeholder="请输入内容" style="width: 320px;"></el-input>
                    <el-button type="primary" icon="el-icon-search" style="margin-left: 15px;" @click="seach()">查询</el-button>
                </div>
                <el-table :data="tableData" border stripe class="table" @selection-change="handleSelectionChange"  ref="multipleTable">
                    <el-table-column prop="id" align="center" label="编号">
                    </el-table-column>
                    <el-table-column prop="executor" align="center" label="执行人 ">
                    </el-table-column>
                    <el-table-column prop="content" align="center" label="执行内容">
                    </el-table-column>
                    <el-table-column prop="executeDate" align="center" :formatter="formatTime" label="执行时间">
                    </el-table-column>
                    <el-table-column prop="executeResult" align="center" label="执行结果 ">
                    </el-table-column>

                </el-table>
                <div class="pagination">
                    <el-pagination background @current-change="handleCurrentChange" layout="prev, pager, next" :total="page_total" :page-size="page_size">
                    </el-pagination>
                </div>
            </div>
        </div>

    </diV>
</template>

<script>
        import {getSystemLog} from '../../../api/index';
    import {famatDatesTimes} from '../../common/com';
    export default {
        name: "systemLog",
        data(){
            return{
                tableData:[],
                value1: '',
                value2:'',
                cur_page: 1,
                page_size: 20,
                page_total: 1,
                multipleSelection: [],
            }
        },
        created() {
            this.getData();
            // this.$nextTick(function () {
            //     this.value1 = famatDatesTimes(new Date());
            // })
        },

        methods:{
            //时间格式
            formatTime(row, column, cellValue, index){
                return famatDatesTimes(cellValue);
            },
            // 分页导航
            handleCurrentChange(val) {
                this.cur_page = val;
                this.getData();
            },
            //选中当前行
            handleSelectionChange(val) {
                console.log(val)
                this.multipleSelection = val;
                if(this.multipleSelection.length > 0 && this.multipleSelection.length <=1){
                    this.istrue = true;
                    console.log(this.multipleSelection.length)
                }else{
                    this.istrue = false;
                    console.log(this.multipleSelection.length)
                }
                console.log(this.istrue)
            },
            // 获取数据以及分页
            getData() {
                getSystemLog({
                    pageNum: this.cur_page,
                    pageSize: this.page_size,
                     executeDate:this.value1
                }).then((res) => {
                      console.log(res)
                     console.log(res.data)
                     this.tableData = res.data.list;
                     this.page_total = res.data.total;
                })
            },
            //查询查询
            seach(){
                var postData = {
                    pageNum:this.cur_page,
                    pageSize:this.page_size,
                    executeDate:this.value1
                }
                this.value2?postData['content']=this.value2 : '';
                getSystemLog(postData).then((res) => {
                    console.log(res)
                    this.tableData = res.data.list;
                    this.page_total = res.data.total;
                     console.log(this.tableData)
                })
             },
        }
    }
</script>

<style scoped>
.demonstration{
    font-size:14px;
    color:#666666;
    margin:0 10px;
}
</style>